Ext.define('AmpleHarvest.objects.usermanagerplugins.usersbygroup.main',
		{
	extend			: 'Ext.window.Window',
	alias			: 'widget.ampleharvest-objects-usermanagerplugins-usersbygroup-main',
	minimizable		: false,
	maximizable		: true,
	width			: 500,
	shim			: false,
	animCollapse	: false,
	constrainHeader	: true,
	modal			: true,
	m_str_group_ID	: null,
	requires		:
	[
			'Ext.form.field.Text'
	],
    listeners       :
    {
    	dataResponse	: function(obj_data)
    	{
    		var importers = Ext.create('Ext.data.Store',
    				{
    					fields	: ['ID', 'UserName'],
    					data	: obj_data.data
    				})
    		var GroupUserDD = Ext.create('Ext.form.field.ComboBox',{
    			fieldLabel		: 'Select Importer',
    			name			: 'importer_sid',
    		    store			: importers,
    		    queryMode		: 'local',
    		    displayField	: 'UserName',
    		    valueField		: 'ID'
    		});
    		
    		this.m_obj_Form = Ext.create("Ext.form.Panel",
    				{
    					bodyStyle	: 'padding:5px 5px 0',
    					frame		: true,
    					buttons		:
    					[
    							{
    								text		: 'Cancel',
    								disabled	: false,
    								scope		: this,
    								handler		: function()
    								{
    									this.close();
    								}
    							},
    							{
    								text		: 'Assign',
    								formBind	: true,
    								disabled	: false,
    								autoWidth	: true,
    								scope		: this,
    								handler		: function()
    								{
    									console.log(this.m_obj_Form.getForm().findField('importer_sid').getValue());
    									
    									Ext.Ajax.request({
    									    url		: 'External/rest/irt/assignUser.php',
    									    method	: 'POST',
    									    params: {
    									        id			: this.m_str_rec_ID,
    									        importer	: this.m_obj_Form.getForm().findField('importer_sid').getValue()
    									    },
    									    success: function(response){
    									        console.log(response);
    									    }
    									});
    									this.AHCaller.fireEvent('reloadData', this);
//    									this.AHCaller.getStore().load();
    									this.close();
    								}
    							}
    					]
    				}
    				);
    		
    		this.m_obj_Form.add(GroupUserDD);
    		
    		this.add(this.m_obj_Form);
    		
    	}
    },

	initComponent	: function()
	{
		this.m_obj_util = Ext.create('AmpleHarvest.util.utility');
		this.m_obj_util.AHcaller = this;
		
		this.callParent();
		
		this.m_obj_util.getData('External/rest/usermanager/usersbygroup.php', { ID : this.m_str_group_ID },{},'GET', {}, {});
		
	}
}
);